﻿using System;
using System.Collections.Generic;

using RexToy.ORM.Dialect;

using Studio.Common;

namespace Studio.Model
{
    public abstract class DatabaseModel : IDatabaseModel
    {
        private static IDatabaseModel _none = new NoneModel();
        public static IDatabaseModel CreateModel(Database db)
        {
            switch (db)
            {
                case Database.SQLServer:
                    return new SQLServerModel();

                case Database.Access:
                    return new OleDbModel();

                case Database.Oracle:
                    return new OracleModel();
            }
            return _none;
        }

        protected string _server;
        public string Server
        {
            get { return _server; }
            set { _server = value; }
        }

        protected string _schema;
        public string Schema
        {
            get { return _schema; }
            set { _schema = value; }
        }

        protected string _username;
        public string UserName
        {
            get { return _username; }
            set { _username = value; }
        }

        protected string _password;
        public string Password
        {
            get { return _password; }
            set { _password = value; }
        }

        protected bool _integratedSecurity;
        public bool IntegratedSecurity
        {
            get { return _integratedSecurity; }
            set { _integratedSecurity = value; }
        }

        public abstract string ConnectString { get; }

        public abstract string Dialect { get; }

        public abstract string Provider { get; }

        public abstract string DialectProvider { get; }

        public abstract void ReadModel();

        protected IEnumerable<ITable> _tables;
        public IEnumerable<ITable> Tables
        {
            get { return _tables; }
        }
    }
}
